<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>编写选择排序，并找出选择排序和冒泡排序的不同点</title>
</head>

<body>
  <script>
    let arr = [45, 12, 78, 23, 56, 89]
    function select(arr) {
      for (let i = 0; i < arr.length; i++) {
        let mei = i;
        for (let j = i + 1; j < arr.length; j++) {
          if (arr[j] < arr[mei]) {
            mei = j;
          }
        }
        temp = arr[i];
        arr[i] = arr[mei];
        arr[mei] = temp;
      }
      return arr
    }
    console.log(select(arr));
  </script>
</body>

</html>